package com.igeek.boot.client;

import com.igeek.boot.entity.Orders;
import com.igeek.boot.service.OrdersService;
import com.igeek.boot.service.OrdersettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author fengqq
 * @Description 统一对外使用业务
 * @Date 2024/8/23  10:00
 *
 * 多数据源下 如何保证事务的一致性？
 *      改变事务的传播行为
 *      //若在执行当前方法时有事务正在工作，将这个外部事务进行挂起，只运行本方法内部的事务
 *     @Transactional(propagation = Propagation.REQUIRES_NEW)
 *
 */
@Service
public class OrdersClient {
    @Autowired
    private OrdersettingService ordersettingService;
    @Autowired
    private OrdersService ordersService;

    @Transactional
    public boolean submit(Orders orders){
        boolean flag1 = ordersService.submitOrder(orders);
        boolean flag2 = ordersettingService.updateByDate(orders);
        return flag1&flag2;
    }
}
